package com.wiz.common.util;

import java.util.Random;

/**
 * 生成相关密钥辅助类
 * @author Hakeny
 */
public class KeyUtil {
	private static byte[] sourceData = {
		0x41,0x42,0x31,0x43,0x44,0x45,0x33,0x46,0x47,0x48,0x49,0x31,0x4A,0x4B,0x4C,0x39,0x4D,0x4E,0x37,0x4F,0x50,0x36,
		0x51,0x52,0x33,0x53,0x54,0x30,0x55,0x56,0x57,0x58,0x59,0x39,0x5A,0x61,0x62,0x32,0x63,0x64,0x34,0x65,0x66,0x36,
		0x67,0x68,0x69,0x38,0x6A,0x6B,0x30,0x6C,0x35,0x6D,0x32,0x6E,0x6F,0x34,0x70,0x71,0x72,0x35,0x73,0x74,0x75,0x76,
		0x77,0x38,0x78,0x79,0x7A,0x37};
	
	public static String resetDynamicKey(){
		byte[] bs = new byte[8];
		int i=0,index=0,max=71,min=0;
		Random random = new Random();
		while(i<8){
			index = random.nextInt(max)%(max-min+1) + min;
			bs[i] = sourceData[index];
			i++;
		}
		return new String(bs);
	}
	
	/**
	 * 生成新的16位激活码
	 * @return
	 */
	public static String getActivationCode(){
		byte[] bs = new byte[16];
		int i=0,index=0,max=71,min=0;
		Random random = new Random();
		while(i<16){
			index = random.nextInt(max)%(max-min+1) + min;
			bs[i] = sourceData[index];
			i++;
		}
		return new String(bs);
	}
	
	public static void main(String[] args) {
		System.out.println(KeyUtil.getActivationCode());
	}
}
